<?php

/**
 * @package HELPERS 
 */
class TToolBarHelper {

    public static $mapButtons = null;

    public static function configMapButton() {
        self::$mapButtons = array(
            'novo' => array('name' => 'Novo', 'icon' => 'icon-new', 'action' => 'cadastrar'),
            'editar' => array('name' => 'Editar', 'icon' => 'icon-copy', 'action' => 'editar', 'param' => 'id'),
            'resgatar' => array('name' => 'Resgatar', 'icon' => 'icon-cloud-2', 'action' => 'resgatar'),
            'excluir' => array('name' => 'Excluir', 'icon' => 'icon-remove', 'action' => 'deletar'),
            'reordenar' => array('name' => 'Reordenar', 'icon' => 'icon-loop', 'action' => 'reordenar'),
            'filtrar' => array('name' => 'Filtrar', 'icon' => 'icon-filter', 'action' => '#'),
            'imprimir' => array('name' => 'Imprimir', 'icon' => 'icon-printer', 'action' => 'imprimir'),
            'publicar' => array('name' => 'Publicar', 'icon' => 'icon-broadcast', 'action' => 'publicar')
        );
    }

    public static function getToolbar() {
        
        /* Configurar o mapeamento do button */
        self::configMapButton();
        
        /* Pecorrer mapButtons */
        $htmlToolBar = '';
        foreach (self::$mapButtons as $toolbar => $config) {
            if(SecurityHelper::getInstancia()->getUsuario()->isToolbarAllow($toolbar)){
                $param = (isset($config['param'])) ? "/{$config['param']}/".CurrentSystemHelper::getCurrentParam($config['param']) : '' ;
                $link = ($config['action'] !== '#') ? 'index.php?'.CurrentSystemHelper::getCurrentController()."/{$config['action']}{$param}" : '#';
                $htmlToolBar .= "<a href='{$link}' id='tb_{$toolbar}'>
                                    <button class=\"shortcut\" >          
                                        <i class='{$config['icon']} fg-gray'></i>
                                        <span class='fg-gray'>{$config['name']}</span>
                                    </button>
                                </a>";
            }
        }
        
        $htmlToolBar = ($htmlToolBar !== '') ? "<div class='toolbar'>{$htmlToolBar}</div>":'';
        return $htmlToolBar;
    }

}

?>
